package wenjian;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import wenjian.Course;
import wenjian.Student;
import wenjian.Teacher;
public class read {
	public static void main(String[] args) throws Exception {
		Student stu0 = new Student(000, "一一");
		Teacher a = new Teacher(001, "老师1", "高数");
		Teacher b = new Teacher(002, "老师2", "线代");
		Teacher c = new Teacher(003, "老师3", "模电");
		System.out.println("学生信息");
		System.out.println(stu0);
		System.out.println("老师信息：");
		System.out.println(a);
		System.out.println("老师信息：");
		System.out.println(b);
		System.out.println("老师信息：");
		System.out.println(c);
		String Name1 = "一一";
		String Password1 = "123";
        FileOutputStream in = new FileOutputStream("C:\\Users\\Desktop\\Test.dat");
        ObjectOutputStream inin = new ObjectOutputStream(in);
        inin.writeObject(1);
        inin.writeObject(2);
		// 序列化持久化对象
		ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(file));
		Course cour0 = new Course(001, "高数", "教101", "周一：13:30-15:10");
		Course cour1 = new Course(002, "线代", "教102", "周二：15:30-17:10");
		Course cour2 = new Course(003, "模电", "教303", "周三：13:30-15:10");

		out.writeObject(cour0);

		out.close();

		// 反序列化，并得到对象
		ObjectInputStream in = new ObjectInputStream(new FileInputStream(file));

		Object newPerson = in.readObject(); // 没有强制转换到Person类型
		in.close();
		System.out.println(newPerson);
	}
}
